﻿
@{
    ViewData["Title"] = "登录";
}
@section style{
    <link rel="stylesheet" href="~/css/index.css?v=0.0.1">
    <style>
        body {
        }

        .loginWraper {
            background: #3283AC url(/images/admin-login-bg.jpg) no-repeat center;
            position: absolute;
            width: 100%;
            left: 0;
            top: 0;
            bottom: 0;
            right: 0;
            z-index: 1;
        }

        .login {
            height: 200px;
            width: 300px;
            padding: 20px;
            background-color: rgba(0,0,0,0.5);
            border-radius: 4px;
            position: absolute;
            left: 50%;
            top: 50%;
            margin: -120px 0 0 -150px;
            z-index: 99;
        }

            .login h1 {
                text-align: center;
                color: #fff;
                font-size: 24px;
                margin-bottom: 20px;
            }

        .login_btn {
            width: 100%;
        }
    </style>
}<div class="loginWraper">
    <div class="login">
        <h1>管理登录</h1>
        <form class="layui-form">
            <div class="layui-form-item">
                <input class="layui-input" name="username" placeholder="用户名" lay-verify="required" type="text" autocomplete="off">
            </div>
            <div class="layui-form-item">
                <input class="layui-input" name="password" placeholder="密码" lay-verify="required" type="password" autocomplete="off">
            </div>
            <button class="layui-btn login_btn" lay-submit="" lay-filter="login">登录</button>
        </form>
    </div>
</div>
@section script{

    <script>

        var $;
        layui.use(['form'], function () {
            var form = layui.form
                , jquery = layui.jquery
                , $ = layui.$;

            //监听提交
            form.on('submit(login)', function (data) {
                var formData = data.field;
                $.post("/Login/Login", formData, function (d) {
                    if (d.code == 0) {
                        location.href = "/";
                    }
                    else {
                        layer.msg(d.msg, { icon: 2 });
                    }
                })
                return false;
            });
            
        });
    </script>
}
